Ok, after fiddling around with this code. This is what I have produced.
Code:
int curChar, nextAvail;
for (curChar = nextAvail = 0; s[curChar]; curChar++)
{
if (s[curChar] != ' ' && s[curChar] != '\t' && s[curChar] != '\n'
&& s[curChar] != '\b')
{
s[nextAvail++] = s[curChar];
}
else
{
if (nextAvail > 0 && s[nextAvail-1] != ' ')
{
s[nextAvail++] = ' ';
}
}
}
s[nextAvail] = 0;
return strlen(s);
My run of the test main(); produces this
Code:
Testing your init function.
Failed test eight, customer should contain:
widget;Acme Co.;gear induction device:♂
your string contained:
widget;Acme Co.;gear induction device:
What the heck is that funky symbol at the end of what it should contain, and what code do I need to fix this up?